﻿<Page 
    x:Class="Perspective.Config.View.DpiScaling"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:p="http://www.codeplex.com/perspective"
    xmlns:vm="clr-namespace:Perspective.Config.ViewModel"
    Style="{StaticResource PageStyle}"
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="300"
    FontSize="14"
    Loaded="Page_Loaded"
	Title="DpiScaling">
    <Page.Resources>
        <vm:ScreenSizeToScaleFactorConverter x:Key="Converter"/>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Margin" Value="0.0, 0.0, 5.0, 0.0" />
        </Style>
    </Page.Resources>
    <p:ResourceStringDecorator 
        AssemblyName="Perspective.Config"
        BaseName="View.Strings.DpiScaling">
        <StackPanel Orientation="Vertical" Margin="25.0, 25.0, 25.0, 25.0">
            <StackPanel Orientation="Vertical" >
                <StackPanel Orientation="Horizontal" >
                    <TextBlock Name="tbSystemDpiText" Text="{p:ResourceString SystemDpiText}"/>
                    <TextBlock Text=":" />
                    <TextBlock Name="tbSystemDpiValueText" />
                </StackPanel>
                <TextBlock Text="{p:ResourceString DefaultRulerSize}"/>
                <TextBlock Text="{p:ResourceString HowToSetScale}"/>
                <Slider x:Name="sScreenSize" Minimum="10.0" Maximum="25.0" />
                <StackPanel Orientation="Horizontal">
                    <TextBlock Name="tbDiagonalScreenSizeText" Text="{p:ResourceString ScreenSize}"/>
                    <!--<TextBox Name="tbDiagonalScreenSizeInput" Text="{Binding  ElementName=sScreenSize, Path=Value, Mode=TwoWay}"/>-->
                    <TextBox Name="tbDiagonalScreenSizeInput">
                        <TextBox.Text>
                            <p:SignalBinding 
                                x:Name="diagonalScreenSizeBinding"
                                ElementName="sScreenSize" Path="Value" 
                                Converting="diagonalScreenSizeBinding_Converting"
                                ConvertingBack="diagonalScreenSizeBinding_ConvertingBack"/>
                        </TextBox.Text>
                    </TextBox>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Name="tbPhysicalDpiText" Text="{p:ResourceString PhysicalDPI}"/>
                    <TextBlock Text=":" />
                    <TextBlock Name="tbPhysicalDpiValueText" Text="{Binding ElementName=tbDiagonalScreenSizeInput, Path=Text, Converter={StaticResource Converter}, ConverterParameter=PhysicalDpi}"/>
                    <TextBlock Name="tbDpiText" Text="{p:ResourceString DpiUnitName}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Name="tbScaleFactorText" Text="{p:ResourceString ScaleFactorToApply}"/>
                    <TextBlock Text=":" />
                    <TextBlock Name="tbScaleFactorValueText" Text="{Binding ElementName=tbDiagonalScreenSizeInput, Path=Text, Converter={StaticResource Converter}, ConverterParameter=ScaleX}"/>
                </StackPanel>
            </StackPanel>
            <ScrollViewer 
                HorizontalScrollBarVisibility="Auto" 
                Margin="0.0, 5.0, 0.0, 0.0"
                Background="White">
                <!--<ScrollViewer.Background>
                    <LinearGradientBrush StartPoint="0,0.5" EndPoint="1,0.5">
                        <GradientStop Color="YellowGreen" Offset="0.0" />
                        <GradientStop Color="White" Offset="1.0" />
                    </LinearGradientBrush>
                </ScrollViewer.Background>-->
                <p:Ruler Length="15.0"  >
                    <p:Ruler.LayoutTransform>
                        <ScaleTransform
                            x:Name="ScreenIndependentScaleTransform"
						    ScaleX="{Binding ElementName=tbDiagonalScreenSizeInput, Path=Text, Converter={StaticResource Converter}, ConverterParameter=ScaleX}"
						    ScaleY="{Binding ElementName=tbDiagonalScreenSizeInput, Path=Text, Converter={StaticResource Converter}, ConverterParameter=ScaleY}"/>
                    </p:Ruler.LayoutTransform>
                </p:Ruler>
            </ScrollViewer>
            <Grid Margin="5.0, 5.0, 5.0, 5.0">
                <Button x:Name="bSaveScale" Width="200.0" Click="bSaveScale_Click" Content="{p:ResourceString ApplyScaleFactor}" />
            </Grid>
        </StackPanel>
    </p:ResourceStringDecorator>
</Page>
